<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <p>PHP SSE</p>
    <p>接收 Server-Sent 事件通知</p>
    <h1>获得服务器更新</h1>
    <div id="result"></div>
    <script>
        if (typeof (EventSource) !== "undefined") {
            var source = new EventSource("php/demo_sse.php");
            source.onmessage = function (event) {
                document.getElementById("result").innerHTML += event.data + "<br />";
            };
        }
        else {
            document.getElementById("result").innerHTML = "抱歉，您的浏览器不支持 server-sent 事件 ...";
        }
    </script>
    <hr />

    <p>ASP SSE</p>
    <p>接收 Server-Sent 事件通知</p>
    <h1>获得服务器更新</h1>
    <div id="result2"></div>
    <script>
        if (typeof (EventSource) !== "undefined") {
            var source = new EventSource("asp/demo_sse.asp");
            source.onmessage = function (event) {
                document.getElementById("result2").innerHTML += event.data + "<br />";
            };
        }
        else {
            document.getElementById("result2").innerHTML = "抱歉，您的浏览器不支持 server-sent 事件 ...";
        }
    </script>
</body>

</html>